yaml-eslint-parser
A YAML parser that produces output compatible with ESLint.
This parser is backed by excellent yaml and yaml-unist-parser packages.
Installation
npm install --save-dev yaml-eslint-parser
Usage
Configuration
Use .eslintrc.*
file to configure parser. See also: https://eslint.org/docs/user-guide/configuring.
Example .eslintrc.js:
module.exports = {
"overrides": [
{
"files": ["*.yaml", "*.yml"],
"parser": "yaml-eslint-parser"
}
]
}
Running ESLint from the command line
If you want to run eslint
from the command line, make sure you include the .yaml
extension using the --ext
option or a glob pattern, because ESLint targets only .js
files by default.
Examples:
eslint --ext .js,.yaml,.yml src
eslint "src/**/*.{js,yaml,yml}"
Editor Integrations
Visual Studio Code
Use the dbaeumer.vscode-eslint extension that Microsoft provides officially.
You have to configure the eslint.validate
option of the extension to check .yaml
files, because the extension targets only *.js
or *.jsx
files by default.
Example .vscode/settings.json:
{
"eslint.validate": [
"javascript",
"javascriptreact",
"yaml"
]
}